"""
各个项目底层登录逻辑
"""
import requests
import pytest
from common.client import RequestsClient
from common.file_load import read_yml

class BaseBuyerApi(RequestsClient):
    """买家服务"""
    # 既然买家n多的接口都要用到token，干脆我在买家父类中定义一个类属性
    # 定义是空，调用接口前先使用登录提取token，给buyer_token赋值
    buy_token = ""
    def __init__(self):
        super().__init__()
        self.session = requests.session()
        self.host = read_yml("/config/http.yml")["buyer"]
        self.headers = {
            "Authorization": BaseBuyerApi.buy_token
        }
        # self.json = None
        # self.params = None
        # self.url = None
        # self.method = None
        # self.files = None
        # self.data = None


    # def request(self,**kwargs):
    #     if "url" not in kwargs:
    #         kwargs["url"] = self.url
    #     if "headers" not in kwargs:
    #         kwargs["headers"] = self.headers
    #     if "method" not in kwargs:
    #         kwargs["method"] = self.method
    #     if "data" not in kwargs:
    #         kwargs["data"] = self.data
    #     if "json" not in kwargs:
    #         kwargs["json"] = self.json
    #     if "params" not in kwargs:
    #         kwargs["params"] = self.params
    #     if "files" not in kwargs:
    #         kwargs["files"] = self.files
    #     self.resp = self.session.request(**kwargs)
    #     return self.resp

class BaseSellerApi(RequestsClient):
    """卖家服务"""
    # 既然卖家n多的接口都要用到token，干脆我在卖家父类中定义一个类属性
    # 定义是空，调用接口前先使用登录提取token，给seller_token赋值
    seller_token = ""
    def __init__(self):
        super().__init__()
        # self.session = requests.session()
        self.host = read_yml("/config/http.yml")["seller"]
        self.headers = {
            "Authorization": BaseSellerApi.seller_token
        }

class BaseAdminApi(RequestsClient):
    """管理员服务"""
    # 既然卖家n多的接口都要用到token，干脆我在卖家父类中定义一个类属性
    # 定义是空，调用接口前先使用登录提取token，给seller_token赋值
    admin_token = ""
    def __init__(self):
        super().__init__()
        # self.session = requests.session()
        self.host = read_yml("/config/http.yml")["manager"]
        self.headers = {
            "Authorization": BaseAdminApi.admin_token
        }

class BaseBasisApi(RequestsClient):
    """基础服务"""
    # 既然卖家n多的接口都要用到token，干脆我在卖家父类中定义一个类属性
    # 定义是空，调用接口前先使用登录提取token，给seller_token赋值
    basis_token = ""
    def __init__(self):
        super().__init__()
        # self.session = requests.session()
        self.host = read_yml("/config/http.yml")["basic"]
        self.headers = {
            "Authorization": BaseBasisApi.basis_token
        }

    # def request(self,**kwargs):
    #     if "url" not in kwargs:
    #         kwargs["url"] = self.url
    #     if "headers" not in kwargs:
    #         kwargs["headers"] = self.headers
    #     if "method" not in kwargs:
    #         kwargs["method"] = self.method
    #     if "data" not in kwargs:
    #         kwargs["data"] = self.data
    #     if "json" not in kwargs:
    #         kwargs["json"] = self.json
    #     if "params" not in kwargs:
    #         kwargs["params"] = self.params
    #     if "files" not in kwargs:
    #         kwargs["files"] = self.files
    #     self.resp = self.session.request(**kwargs)
    #     return self.resp